home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / comm / www / WWWworkbenchIB.lha / WWWworkbench / WWWworkbench.ibrx < prev   
Encoding:
Text File  |  1998-09-29  |  9.2 KB  |  269 lines

  1. /* $VER: WWWworkbench.ibrx  1.0
  2. *Made by Andres Pääbo (c)1998 : paabo@bancom.net
  3. *
  4. */
  5. OPTIONS RESULTS
  6. fileonly=0 /*initialize */
  7. IF ~ SHOW('L', "rexxsupport.library") then addlib('rexxsupport.library', 0, -30,0)
  8.  
  9. ADDRESS 'IBROWSE'
  10. brf='file://localhost/'
  11. cfg='IB'
  12.  
  13. IF  EXISTS('RAM:W4')=0 THEN
  14. ADDRESS COMMAND 'MAKEDIR  RAM:W4'
  15. ENDIF
  16. W4config=OPEN('configfile', 'RAM:W4/W4'cfg'config.txt', 'Read') 
  17.     if  W4config=0 then DO
  18.      W4config=OPEN('configfile', 'WWWworkbench/W4config.txt', 'Read') 
  19.         if  W4config=0 then DO  
  20.         screen="Workbench"
  21.         width=100
  22.         height=90
  23.         spacing=3
  24.         rowacross=3
  25.         maxautosize=15
  26.         FTPM.1='FTPMount:drwrname/public_html/'
  27.         WWW.1='http://www.server.com/~myname/'
  28.         FTPM.2=' '
  29.         WWW.2=' '
  30.         FTPM.3=' '
  31.         WWW.3=' '
  32.         FTPM.4=' '
  33.         WWW.4=' '
  34.         END
  35.     END
  36.  
  37.  if  W4config~=0 then DO WHILE~EOF('configfile') 
  38.     line = READLN('configfile')
  39.     if  INDEX(line,'*')~=0 then iterate
  40.     if line='' then leave
  41.     line2 = STRIP(line)
  42.     interpret  line2
  43.     END
  44. CLOSE('configfile')
  45.     /******END OF CONFIGURATION SECTION******/
  46.  
  47. refresh=getclip('refresh')
  48. if refresh=2 then refresh='' /*just for below--clone*/
  49. newdrawer=getclip('newdrawer') /*turned to 1 if new, off at end of this, 2 is special case*/
  50.  
  51. call setclip('screen',screen)  /*needed by programs with requesters*/
  52.  
  53. oldcurrdir=getclip('currdir')/*from another script*/
  54.  
  55.  
  56. 'QUERY TITLE'
  57.  
  58. currdir=result
  59. if oldcurrdir~='' then currdir=oldcurrdir
  60. reqdir=currdir
  61.  
  62. if newdrawer=1 then reqdir=getclip('oldreqdir')
  63. /*use old path since a new window has no filepath info*/
  64.  
  65. refresh=getclip('refresh') /*keep in for clone*/
  66. /*if refresh='' then a support script has NOT told us not to 
  67. *generate the requester but to go with the current directory and redo the page*/
  68.  
  69. FILEREQUESTER:
  70. if refresh='' then DO
  71.     ADDRESS COMMAND 'REQUESTFILE > "RAM:W4/resultstring"   TITLE "Select DIRECTORY TO LOAD "  NOICONS  PUBSCREEN 'screen' DRAWER "'reqdir'" '
  72.         IF rc=5 then  call noload
  73.         if rc=20 then call reqfail
  74.     call open('resultstring','Ram:W4/resultstring',R)
  75.     resultstring=readln('resultstring')
  76.     resultstring=TRANSLATE(resultstring, ' ','"')
  77.     resultstring=STRIP(resultstring)
  78.     close('resultstring')
  79.     currdir=resultstring
  80.     if RIGHT(currdir,1)~='/' & RIGHT(currdir,1)~=':' then DO
  81.         slashpos=LASTPOS('/',currdir)
  82.         if slashpos=0 then slashpos=LASTPOS(':',currdir)
  83.         file=SUBSTR(currdir,slashpos+1)
  84.         currdir=LEFT(currdir,slashpos)
  85.         fileonly=1
  86.         END
  87.     END
  88.  
  89.  
  90. /*detect if user loading an FTPMount directory*/
  91. FTPMtest=LEFT(currdir,9)
  92. IF  FTPMtest = 'FTPMount:'then  call remotehost
  93. ELSE  DO
  94.     shocurrdir=currdir
  95.     urlstart="file://localhost/"
  96.     END
  97.  
  98.  
  99. urlpath=urlstart||shocurrdir  
  100. /***DONE****we have  directory name and what we use for the url**********/
  101.  
  102. /*deal with when user actually selects a file*/
  103. if fileonly=1 then call fileonly  /*send file to viewing if file chosen in filerequester*/
  104.  
  105. /*get a name for the generated thumnail document*/
  106. len=LENGTH(shocurrdir)
  107. shocurrdir2=LEFT(shocurrdir, len-1)
  108. nextpos=LASTPOS('/',shocurrdir2)
  109. if nextpos=0 then nextpos=LASTPOS(':',shocurrdir2)
  110. currdirnoroot=SUBSTR(shocurrdir2,nextpos+1)
  111. thumbname= currdirnoroot'-PICS.HTML'
  112.  
  113. /*display stuff*/
  114. ws=(width + spacing+spacing)*rowacross
  115.  
  116. /*get the directory files and extract  information*/
  117. IF  EXISTS('RAM:W4')=0 THEN
  118. ADDRESS COMMAND 'MAKEDIR  RAM:W4'
  119. ENDIF
  120. empty=0
  121. ADDRESS COMMAND'List 'currdir'  TO RAM:W4/FILELIST NOHEAD LFORMAT="%-30N %L %20A %D"'
  122. looklist=OPEN('lookfile', 'RAM:W4/FILELIST', 'Read') 
  123. x=readln('lookfile')
  124. if x='' then  empty=1
  125. close ('lookfile')
  126. /* sort alphabetically */
  127. ADDRESS COMMAND 'Sort RAM:W4/FILELIST TO RAM:W4/SORTEDLIST'
  128. close('lookfile')
  129.  
  130. /*****large section below :go through list and generate the html document****/
  131.  
  132. infilelist=OPEN('infile', 'RAM:W4/SORTEDLIST', 'Read') 
  133. outfilelist=OPEN('outfile', 'RAM:W4/'thumbname, 'Write') 
  134. W4topmenu=''
  135. insert=OPEN('topmenu', 'RAM:W4/W4topmenu',Read)
  136. if insert~=0 then W4topmenu=READLN('topmenu')
  137. CLOSE('topmenu')
  138.  
  139. htmlopen='<HTML><TITLE>'currdir'</TITLE><BODY  TEXT="#000000"  BGCOLOR="#666666" TEXT="#FFFFFF" LINK="#9999FF" ALINK="#9999FF" VLINK="#9999FF"><CENTER> <A HREF= "'brf'WWWworkbench/W4new.ibrx"><IMG SRC="file://localhost/WWWworkbench/drawer.jpg" ></A> . <FONT SIZE=1>'currdir' . <A HREF="'brf'WWWworkbench/W4parent.ibrx"> <I>PARENT</A>  .  
  140. <A HREF="'brf'WWWworkbench/W4refresh.ibrx"> REFRESH</A> .  
  141. <A HREF="'brf'WWWworkbench/W4clone.ibrx"> CLONE </I></A><BR><NOBR><A HREF= "'brf'WWWworkbench/W4delete.ibrx">Delete</A> . <A HREF= "'brf'WWWworkbench/W4copytoother.ibrx"> CopyTo</A> . <A HREF= "'brf'WWWworkbench/W4movetoother.ibrx"> MoveTo</A> . <A HREF= "'brf'WWWworkbench/W4rename.ibrx"> Rename</A> . <A HREF= "'brf'WWWworkbench/W4clonefiles.ibrx">Clone</A> . <A HREF= "'brf'WWWworkbench/W4makedir.ibrx"> MakeDir</A> . <A HREF= "'brf'WWWworkbench/W4deletedir.ibrx"> DelDir</A>. <A HREF= "'brf'WWWworkbench/W4arexx.ibrx"> Arexx</A>  </FONT></NOBR></TD></TR></TABLE></NOBR><TABLE CELLSPACING='spacing'><TR>'
  142.  
  143. WRITELN('outfile',htmlopen)
  144. /* go through the list one by one */
  145. if empty=1 then signal 'empty'
  146. rowcnt=rowacross
  147.  
  148. n=0
  149. DO WHILE ~EOF('infile')
  150.     line = READLN('infile')
  151.     nextfile=LEFT(line, 30)
  152.     nextfile=STRIP(nextfile)
  153.     IF nextfile ~= "" THEN DO
  154.         IF RIGHT(nextfile,5)='.INFO' THEN ITERATE
  155.         IF RIGHT(nextfile,5)='.info' THEN ITERATE
  156.         n=n+1
  157.         date=RIGHT(line,9)
  158.         date=TRANSLATE(date,' ','-')
  159.         date=COMPRESS(date)
  160.         filesize=SUBSTR(line, 31,16)
  161.         filesize=COMPRESS(filesize)
  162.         ln=LENGTH(filesize)
  163.         if ln>2 then size=DELSTR(filesize, ln-2)
  164.             ELSE size='0'
  165.         if  size='' then size='>1'
  166.  
  167.         htmlline='<TD WIDTH='width+3' ALIGN=CENTER VALIGN=TOP><A HREF="'urlpath||nextfile'" TARGET="_TOP"><IMG SRC="'urlpath||nextfile'" WIDTH='width' HEIGHT='height' ></A><BR><FONT SIZE=1  COLOR="#FFFFFF">'nextfile' <BR><FONT COLOR="#FFBB66">'size'k 'date' </FONT></TD>'
  168.  
  169.         if size>maxautosize then call maxauto
  170.  
  171.         /*special attention to html documents*/
  172.         ext=RIGHT(nextfile,4)
  173.         ext2=RIGHT(nextfile,5)
  174.         SELECT
  175.         WHEN ext='.HTM' then call htmldoc
  176.         WHEN ext='.htm' then call htmldoc
  177.         WHEN ext2='.html' then call htmldoc
  178.         WHEN ext2='.HTML' then call htmldoc
  179.         OTHERWISE NOP
  180.         END
  181.  
  182.         if filesize='Dir' then  call directory
  183.  
  184.         WRITELN('outfile',htmlline)
  185.  
  186.         if n=rowcnt then DO
  187.             WRITELN('outfile','</TR><TR>');rowcnt=rowcnt+rowacross
  188.             END
  189.         END
  190.     END
  191. /****html doc generated now close up**/
  192. EMPTY:
  193. htmlclose='</TR></TABLE ><BR></CENTER></BODY></HTML>'
  194. WRITELN('outfile',htmlclose)
  195. call CLOSE('infile')
  196. call CLOSE('outfile')
  197.  
  198. /*outfile should be the html page. Now load it. But first determine to which frame, left or right*/
  199.  
  200.  'GOTOURL file://localhost/Ram:W4/'thumbname
  201.  
  202. /*cleanup*/
  203. ADDRESS COMMAND 'Delete "RAM:W4/FILELIST" QUIET'
  204. ADDRESS COMMAND 'Delete "RAM:W4/SORTEDLIST" QUIET'
  205.  ADDRESS COMMAND 'Delete "RAM:W4/'thumbname'" QUIET'
  206. ADDRESS COMMAND 'Delete "RAM:W4/resultstring" QUIET'
  207. /*loose ends*/
  208.  call setclip('refresh', '') /*job done restore reqfile op'n to '0' in cliplist*/
  209. call setclip('currdir','')
  210. call setclip('newdrawer',0)
  211. call setclip('oldreqdir',currdir)
  212. EXIT 0
  213.  
  214. htmldoc:
  215. htmlline='<TD WIDTH='width+3'  ALIGN=CENTER  VALIGN=TOP><A HREF= "'urlpath||nextfile'"TARGET="_TOP"><IMG SRC="file://localhost/WWWworkbench/html.jpg" WIDTH='width' HEIGHT='height'></A><BR><FONT  SIZE=1 COLOR="#FFFFFF">'nextfile'<BR><FONT COLOR="#FFBB66">'size' K 'date'<BR></FONT></TD>'
  216. return
  217.  
  218. maxauto:
  219. htmlline='<TD WIDTH='width+3'  ALIGN=CENTER  VALIGN=TOP><A HREF= "'urlpath||nextfile'" TARGET="_TOP"><IMG SRC="file://localhost/WWWworkbench/bigpic.jpg" WIDTH='width' HEIGHT='height'></A><BR><FONT  SIZE=1 COLOR="#FFFFFF">'nextfile'<BR><FONT COLOR="#FFBB66">'size' K 'date'<BR></FONT></TD>'
  220. return
  221.  
  222.  
  223. directory:
  224. htmlline='<TD WIDTH='width+3'  ALIGN=CENTER VALIGN=TOP ><A HREF= "'brf'WWWworkbench/W4new.ibrx"><IMG SRC="file://localhost/WWWworkbench/drawer.jpg" WIDTH='width' HEIGHT='height'></A> <BR><FONT SIZE=1>'nextfile'</B></FONT></TD>'
  225. return
  226.  
  227. remotehost:
  228. DO  i=1 to 20     /*the 20 is arbitrary. most people will only have a couple*/ 
  229. Lftpmni=LENGTH(FTPM.i)
  230. compare=COMPARE(currdir,FTPM.i)
  231. if compare=0 then LEAVE 
  232. if compare >Lftpmni then  LEAVE 
  233. END
  234. if compare=0 then shocurrdir=WWW.i
  235. if compare>Lftpmni then DO 
  236.     deeperstuff=SUBSTR(currdir, compare)
  237.     shocurrdir=WWW.i||deeperstuff
  238.     END
  239. if compare~=0 & compare~>Lftpmni then DO
  240.  Say 'WWWworkbench could not find an http address for the FTPMount directory'
  241. Say ' that you selected. You need to establish it in your  configuration'
  242. ADDRESS COMMAND 'WAIT 3'
  243. EXIT
  244. END
  245. urlstart=''  /*we ask user to include the http:*/
  246. return
  247.  
  248. fileonly:
  249. 'GOTOURL 'urlpath||file'' 
  250. EXIT 0
  251.  
  252. noload:
  253. if newdrawer=2 then DO; call setclip('newdrawer',0);EXIT;END
  254. noload=OPEN('window', 'RAM:W4/window.html','Write')
  255. htmlwindow='<HTML><TITLE>'currdir'</TITLE><BODY><BR><BR><BR><CENTER><A HREF="'brf'WWWworkbench/WWWworkbench.ibrx"><FONT SIZE=2>OPEN a <IMG SRC="file://localhost/WWWworkbench/drawer.jpg"> DRAWER</A></FONT></CENTER></BODY></HTML>'
  256. WRITELN('window', htmlwindow)
  257. close('window')
  258.  'GOTOURL file://localhost/Ram:W4/window.html'
  259. EXIT
  260.  
  261. reqfail:
  262. ADDRESS COMMAND 'C:REQUESTCHOICE >RAM:W4/resultstring 
  263. "ALERT"  "File Requester failed.Probably  screen specified in  config file non-existent. Fix config file . " "for now: put on Workbench?|CANCEL"'
  264. call open('resultstring','Ram:W4/resultstring',R)
  265. response=readln('resultstring')
  266. close('resultstring')
  267. if response=0 then EXIT
  268. if response=1 then DO; screen='Workbench';signal filerequester;END
  269. return